package com.supermap.originTest;


import java.util.ArrayList;
import java.util.List;


public class ConversationTest {

    /**
     * 程序入口点
     * The entrance of the programme.
     */
    public static void main(String[] args) {


		double[] students = new double[200];
		for(int i=0;i<200;i++){
			students[i]=1+i*4.5+genOffSet();
			System.out.println(students[i]);
		}


		System.out.println(removeElements(students).length);
	}

	static double genOffSet(){
		return 0.9-Math.random()*1.8;
	}


	static double[] removeElements(double[] arr) {
		List<Double> resultList = new ArrayList<>();

		for (int i = 0; i < arr.length - 1; i++) {
			if (Math.abs(arr[i] - arr[i + 1]) >= 4) {
				resultList.add(arr[i]);
			} else {
				i++; // 跳过下一个元素
			}
		}

		// 添加最后一个元素
		if (arr.length > 0) {
			resultList.add(arr[arr.length - 1]);
		}

		// 转换为数组
		double[] result = new double[resultList.size()];
		for (int i = 0; i < resultList.size(); i++) {
			result[i] = resultList.get(i);
		}

		return result;
	}


}  

